/**
 * Author atguigu
 * Date 2020/11/20 14:09
 */
object OptionDemo1 {
    def main(args: Array[String]): Unit = {
        val opt: Option[Int] = fun()
        
       /* if (opt.isDefined) {
            println(opt.get)
        }
        opt.isEmpty*/
    
       /* val opt1: Option[Int] = opt.map(x => x * 2)
        println(opt1.get)
        
        */
        /*opt match {
            case Some(a) =>
                println(a)
            case None =>
                println("xxx")
        }*/
    
        val e: Either[String, Int] = fun1()
        
        /*if (e.isLeft) {
            println(e.left.get)
        }else{
            println(e.right.get)
        }*/
        e match {
            case Left(msg) =>
            case Right(a) =>
        }
        
    }
    
    def fun1():Either[String, Int] = {
//        Left("not ok")
        Right(20)
    }
    
    def fun(): Option[Int] = {
                Option(10)
//        None
    }
}
/*
Either
    两种可能, 一个是正确的一个错误的
    
    Left  错误
    Right  正确
 */